# 2.6 configInterceptor

# 1. Configuring Global Interceptors

The configInterceptor method is used to configure global interceptors. Global interceptors are divided into two categories: Control Layer and Business Layer. Below is a configuration example:

public void configInterceptor(Interceptors me) {
    // The following two lines of code configure global interceptors for the control layer
    me.add(new AuthInterceptor());
    me.addGlobalActionInterceptor(new AaaInterceptor());
    
    // The line below configures the global interceptor for the business layer
    me.addGlobalServiceInterceptor(new BbbInterceptor());
}
1
2
3
4
5
6
7
8

The above methods me.add(...) and me.addGlobalActionInterceptor(...) are completely equivalent and both configure interceptors that intercept all action methods in Controllers. Meanwhile, the interceptor configured by me.addGlobalServiceInterceptor(...) will intercept all public methods in the business layer.

Note: The so-called "business layer" mentioned above essentially refers to anything other than the "control layer". It doesn't necessarily have to be the business layer; it could be any class other than the controller.

Interceptors configured in the manner mentioned above can be removed at the method definition location using the @Clear annotation. The specific usage will be detailed in subsequent sections related to the @Clear annotation.

# 2. Levels/Granularity of Interceptor Configuration

The granularity of Interceptor configuration is divided into four levels: Global, Routes, Class, and Method. The configuration granularity mentioned above is global. Configurations for the Routes, Class, and Method levels will be detailed in subsequent sections.

Last Updated: 9/17/2023, 5:34:57 AM